package org.noranj.ws;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import org.noranj.data.DAService;
import org.noranj.dto.ConversationDTO;




@Path("/conversationservice/")
public class Conversation {
    
  @GET
  @Path("/conversations/")
  @Produces("application/json")
  public List<ConversationDTO> getConversation(){
    List<ConversationDTO> mylist = new ArrayList<ConversationDTO>();
    for (ConversationDTO row : DAService.getInstance().getConversation().values()){
      mylist.add(row);
    }
    return mylist;
 }
  
  @POST
  @Path("/addrow/")
  public Response addConversation(@PathParam("converationrow") ConversationDTO converationRow){
    DAService.getInstance().getConversation().put(String.valueOf(converationRow.getIdConversation()) ,converationRow);
    return Response.ok(converationRow).build();
    
  }
  
  @DELETE
  @Path("/deleteall/")
  public Response deleteConversation(){
    DAService.getInstance().getConversation().remove(null);
    return Response.ok().build();
    
  }
  
  @GET
  @Path("/about")
  public String about() {
    return("Jingle Board version 1.0");
  }
}
